<?php
namespace app\backstage\model;
use think\Db;
use think\Model;

class Setting extends Model
{
    protected $table = 'cps_setting';

    /*获取单条记录*/
    public function getOne($where, $field = '*')
    {
        $info = Db::table($this->table)->where($where)->field($field)->findOrEmpty();
        return $info;
    }

    /*获取所有列表记录*/
    public function getAllList($where, $field = '*', $orderBy = [], $groupBy = '')
    {
        $list = Db::table($this->table)->where($where)->field($field)
            ->order($orderBy)->group($groupBy)->select();

        return $list ? $list : [];
    }

    /*更新记录*/
    public function updateRecord($where,$data)
    {
        $res = Db::table($this->table)->where($where)->update($data);
        return $res >= 0 ? true : false;
    }

    /*添加记录*/
    public function insertRecord($data)
    {
        $res = Db::table($this->table)->insert($data);
        return $res > 0 ? true : false;
    }

}